package com.happle.gcmclient.backendmanager.task;

import android.os.AsyncTask;
import android.util.Log;

import com.happle.gcmclient.backendmanager.BackendManager;
import com.happle.gcmclient.config.Constants;
import com.happle.gcmclient.obj.MessageObj;

import java.util.ArrayList;

/**
 * Created by Inna on 29.11.13.
 */
public class DownloadConversationsTask extends AsyncTask<Void, Void, ArrayList<MessageObj>> {
    private String regId = "";
    private int lastConvId = 0;
    private int moreConvNum = Constants.DOWNLOAD_MSG_PACKAGE;

    public DownloadConversationsTask (String registration_id, int last_conversation_id, int more_conversation_number) {
        regId = registration_id;
        lastConvId = last_conversation_id;
        moreConvNum = more_conversation_number;
    }
    @Override
    protected ArrayList<MessageObj> doInBackground(Void... params) {
        ArrayList<MessageObj> downloadedConversations = new ArrayList<MessageObj>();
        try {
            BackendManager bManager = new BackendManager();
            downloadedConversations = bManager.getMoreConversations(regId, lastConvId, moreConvNum);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return downloadedConversations;
    }
}
